<template>
  <div class="active">
        <el-table
      :data="list"
      style="width: 100%">
      <el-table-column
        prop="date"
        label="日期"
        width="180">
      </el-table-column>
      <el-table-column
        prop="name"
        label="姓名"
        width="180">
      </el-table-column>
      <el-table-column
        label="评论内容">
        <template v-slot="{row}">
            评论描述:&nbsp;{{row.address}}<br>
            附加图片:<br>
          <img v-for="(item,index) in row.image" :key="index" :src="item" alt="" style="width:70px;margin-left:10px;border-radius: 10px;"><br>
            {{row.date}}
        </template>
      </el-table-column>
      <el-table-column
        prop="name"
        label="评论人"
        width="180">
      </el-table-column>
      <el-table-column
        prop="address"
        label="商品信息"
        width="180">
      </el-table-column>
        <el-table-column
        label="操作"
        width="180">
        <template>
          <el-button type="text">回复</el-button>
          <el-button type="text" @click="hdelete(row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>
import {comments,xdelete} from '@/api/login'
export default {
data() {
        return {
         list:[],
         q:{
          index:1,
          size:10
         }
        }
      },
       created(){
        this.loachedn()
       },
       methods:{
       async loachedn(){
          const res = await comments(this.q)
          this.list = res.data.data
        },
        // 删除
        hdelete(row){
          this.$confirm('确定要删除么?','提示',{
            confirmButtonText:'确定',
            cancelButtonText:'取消',
            type:'warning'
          }).then(async() => {
            const params = new URLSearchParams()
            params.append('id',row.id)
            const res = await xdelete(params)
            this.$message.success(res.msg)
          })
          .catch(()=>{})
        }
       }
}
</script>

<style scoped>
   .active{
    padding-left: 20px;
    background-color: #fff;
   }
</style>